program CountTransition
implicit none

integer i,j,k,ios,nargs,totframe,Num
character(len=79)ARGUMENT,INPUT
character(len=10),dimension(2) :: tmp
character(len=10) :: s(199999),prestate

 nargs=iargc()
	if(nargs==1)then
	call getarg(1,INPUT)
	else
	write(*,*) "Wrong Input!"
	write(*,*) "$0 TransitionQueue.dat!"
	write(*,*) "$0 ubub.dat"
	goto 1000
	endif

ios=0
i=0
open(10,file=INPUT,status="old")
do while(.true.)
 read(10,"(A)",iostat=ios)ARGUMENT
 if(ios/=0)exit
 i=i+1
 read(ARGUMENT,*) (tmp(k),k=1,2)
 s(i)=tmp(2)
enddo
close(10)

Num=0
totframe=i
prestate=s(1)
 do j=1,totframe
 if(s(j)/=prestate)then
  Num=Num+1
 endif
 prestate=s(j)
 enddo
write(*,*) Num
1000 end program
